<template>
    <div>
        <inner-breadcrumb
            @input="breadcrumbChange"
            v-model="key"
            :path="{
        label: '微专业培养方案管理',
        key: 'cultureList',
        children:[
        {
        key: 'addCultureScheme',
        label:this.$t('minor.culture.basicInfo')
        },{
        key: 'viewCultureScheme',
        label:'查看方案'
        },{
        key: 'addCourseType',
        label:this.$t('minor.culture.courseType')
        },{
        key: 'addCourseSet',
        label:this.$t('minor.culture.courseSet')
        },{
        key: 'addChapterSet',
        label:this.$t('minor.culture.chapterSet'),
        children:[{
            key: 'relationTable',
            label:this.$t('minor.culture.relationTable')
        },{
        key: 'catChapter',
        label:this.$t('minor.culture.catChapter')
        }]
        }]
        }"
        />
        <div class="edu-page-warp" v-if="key=='cultureList'">
            <condition-card @reset="resetQuery" @search="searchData">
                <!--事件-->
                <el-form label-width="120px" label-position="right" label-suffix=":">
                <el-row :gutter="20">
                    <el-col :span="8">
                        <el-form-item label="辅修年级">
                            <el-date-picker
                                v-model="queryParams.minorGrade"
                                type="year"
                                clearable
                                value-format="yyyy"
                                style="width: 100%;"
                                :placeholder="$t('message.plzSelect')"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item :label="$t('minor.major.college')">
                            <DictSelect
                                v-model="queryParams.collegeCode"
                                :data="options.college"
                                :clearable="canSelectFaculty"
                                :filterable="true"
                                style="width: 100%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                     <el-col :span="8">
                        <el-form-item label="审核状态">
                            <DictSelect
                                v-model="queryParams.status"
                                :data="approveStatus"
                                clearable
                                style="width:100%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="8">
                        <el-form-item :label="$t('minor.course.advancedLevel')">
                            <DictSelect
                                v-model="queryParams.advancedLevel"
                                :data="options.advancedLevel"
                                clearable
                                style="width:100%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col> -->
                </el-row>
                </el-form>
            </condition-card>
            <el-card shadow="never">
                <div class="first_title">微专业培养方案管理列表</div>
                <div class="btn">
                    <el-button type="primary" @click="copy">复制</el-button>
                    <el-button
                        type="primary"
                        @click="addCultureTemplateInfo"
                        v-if="addBtn"
                    >{{$t('minor.course.addBtn')}}</el-button>
                    <el-button type="danger"  v-if="addBtn" @click="deleteCultureScheme('', true)">删除</el-button>
                    <el-button type="primary" @click="exprtTraining">导出</el-button>
                    <!-- <el-button type="primary" @click="batchAddCultureScheme" v-if="addBtn">批量创建</el-button> -->
                    
                </div>
                <EduTable
                    :selection="true"
                    @page-change="pageChange"
                    :data="tableData.list"
                    :total="tableData.total_"
                    :pageSize="page.pageSize"
                    :pageNum="page.pageNum"
                    @selection-change="chooseRow"
                >
                    <el-table-column label="方案名称" show-overflow-tooltip>
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="previewCulture(scope.row)"
                                size="mini"
                            >{{scope.row.name}}</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column label="辅修年级" show-overflow-tooltip>
                        <template slot-scope="scope">{{scope.row.minorGrade}}</template>
                    </el-table-column>
                    <el-table-column :label="$t('minor.major.college')" show-overflow-tooltip>
                        <template slot-scope="scope">{{scope.row.collegeCodeI18n}}</template>
                    </el-table-column>
                    <el-table-column label="辅修专业" show-overflow-tooltip>
                        <template slot-scope="scope">{{scope.row.majorNameCn}}</template>
                    </el-table-column>
                    <!-- <el-table-column
                        :label="$t('minor.course.advancedLevel')"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">{{scope.row.advancedLevelName}}</template>
                    </el-table-column> -->
                    <el-table-column
                        label="审核状态"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.status == '0'"
                                type="info"
                                size="mini"
                                disable-transitions
                            >{{ getPushLable(scope.row.status) }}</el-tag>
                            <el-tag
                                v-if="scope.row.status == '2'"
                                type="warning"
                                size="mini"
                                disable-transitions
                            >{{ getPushLable(scope.row.status) }}</el-tag>
                            <el-tag
                                v-if="scope.row.status == '1'"
                                type="success"
                                size="mini"
                                disable-transitions
                            >{{ getPushLable(scope.row.status) }}</el-tag>
                            <el-tag 
                                v-if="scope.row.status == 4" 
                                type="danger" 
                                size="mini"
                            >变更中</el-tag>
                        </template>
                    </el-table-column>
                     <el-table-column label="下一级审核人" show-overflow-tooltip>
                        <template slot-scope="scope">{{ scope.row.approveName}}</template>
                    </el-table-column>
                    <el-table-column :label="$t('message.operating')">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="viewRecord(scope.row)"
                                v-if="scope.row.status == '1' || scope.row.status == '2'"
                                size="mini"
                            >{{$t('minor.course.viewBtn')}}</el-button>
                            <el-button
                                type="text"
                                @click="editCultureScheme(scope.row)"
                                v-if="scope.row.status == '0' || scope.row.status == 4"
                                size="mini"
                            >{{$t('minor.course.editBtn')}}</el-button>
                            <el-button
                                type="text"
                                @click="deleteCultureScheme(scope.row)"
                                v-if="(scope.row.status == '0' || scope.row.status == 4) && addBtn"
                                size="mini"
                            >{{$t('minor.course.deleteBtn')}}</el-button>
                            <el-button
                                type="text"
                                @click="upChange(scope.row)"
                                v-if="scope.row.status == 1"
                                size="mini">变更</el-button>
                        </template>
                    </el-table-column>
                </EduTable>
            </el-card>
            <edu-dialog ref="batchAddDialog" title="批量创建培养方案" width="50%">
                <el-form
                    :model="batchCultureScheme"
                    ref="batchCultureScheme"
                    label-width="100px"
                    :rules="batchBasicRules"
                >
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="辅修年级:" prop="minorGrade">
                                <el-date-picker
                                    v-model="batchCultureScheme.minorGrade"
                                    type="year"
                                    clearable
                                    value-format="yyyy"
                                    style="width: 100%;"
                                    placeholder="选择辅修年级"
                                    @change="getProfession('2')"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item :label="$t('minor.major.college') + ':'" prop="collegeCode">
                                <DictSelect
                                    v-model="batchCultureScheme.collegeCode"
                                    :data="options.college"
                                    :clearable="true"
                                    :filterable="true"
                                    labelAll="请选择"
                                    @change="getProfession('2')"
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <!-- <el-col :span="24">
                            <el-form-item label="进阶层次:" prop="advancedLevel">
                                <DictSelect
                                    v-model="batchCultureScheme.advancedLevel"
                                    :data="options.advancedLevel"
                                    clearable
                                    labelAll="请选择"
                                    @change="getCultureTemplate(1)"
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col> -->
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="培养方案模板:" prop="cultueTemplate">
                                <DictSelect
                                    v-model="batchCultureScheme.cultueTemplate"
                                    :data="options.cultueTemplate"
                                    :clearable="true"
                                    :filterable="true"
                                    labelAll="请选择"
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="专业:" prop="profession">
                                <DictSelect
                                    v-model="batchCultureScheme.profession"
                                    :data="options.profession"
                                    :clearable="true"
                                    :filterable="true"
                                    multiple
                                    labelAll="请选择"
                                    style="width:100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <span slot="buttons">
                    <el-button @click="cancelBatch">取消</el-button>
                    <el-button type="primary" @click="confirmBatch">确定</el-button>
                </span>
            </edu-dialog>
        </div>
        <div  v-if="key !='cultureList' && key != 'viewCultureScheme'" style="margin: 4px 4px 16px;">
            <el-card shadow="never">
                <div class="stepstyle">
                    <el-steps :active="defaultValue" align-center>
                        <el-step title="基础信息"></el-step>
                        <el-step title="课程性质"></el-step>
                        <el-step title="课程设置"></el-step>
                        <el-step title="章节设置"></el-step>
                    </el-steps>
                </div>
            </el-card>
        </div>
        <!-- <div class="edu-page-title title-span" v-if="key !='cultureList' && key != 'viewCultureScheme'">
            <el-steps :active="defaultValue" align-center>
                <el-step title="基础信息"></el-step>
                <el-step title="课程类别"></el-step>
                <el-step title="课程设置"></el-step>
                <el-step title="章节设置"></el-step>
            </el-steps>
            <span
                v-for="(item, index) in topNavItems"
                :class="{active: item.value == key}"
                :key="index"
                class="border-right"
                @click="clickItem(item, index)"
                >{{ item.label }}</span>
        </div> -->
        <div class="edu-page-warp" v-if="key=='addCultureScheme'">
            <el-card shadow="never">
                <div class="parentDiv">
                    <div class="templateFont" v-if="disabledBtn">编辑方案</div>
                    <div class="templateFont" v-if="!disabledBtn">查看方案</div>
                </div>
                <el-form
                    :model="createbasicForm"
                    ref="createbasicForm"
                    label-width="100px"
                    :rules="reBasicRules"
                >
                    <el-row>
                        <el-col :span="8">
                            <el-form-item>
                                <el-checkbox v-model="schemeForm.checked" disabled>自动命名</el-checkbox>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8"> 
                            <el-form-item label="方案名称" prop="schemeName">
                                <el-input
                                    ref="schemeName"
                                    v-model="createbasicForm.schemeName"
                                    :disabled="!disabledBtn"
                                    :placeholder="'自动命名：辅修年级+' + $t('minor.major.college') + '+辅修专业'"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="英文名称">
                                <el-input
                                    v-model="createbasicForm.schemeNameEn"
                                    :disabled="!disabledBtn"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="辅修年级" prop="minorGrade">
                                <el-date-picker
                                    v-model="createbasicForm.minorGrade"
                                    type="year"
                                    clearable
                                    disabled
                                    value-format="yyyy"
                                    style="width: 100%;"
                                    :placeholder="$t('message.plzSelect')"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('minor.major.college')" prop="collegeCode">
                                <DictSelect
                                    v-model="createbasicForm.collegeCode"
                                    :data="options.college"
                                    :clearable="true"
                                    :filterable="true"
                                    disabled
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <!-- <el-col :span="8">
                            <el-form-item
                                :label="$t('minor.course.advancedLevel')"
                                prop="advancedLevel"
                            >
                                <DictSelect
                                    v-model="createbasicForm.advancedLevel"
                                    :data="options.advancedLevel"
                                    :clearable="true"
                                    :filterable="true"
                                    disabled
                                    style="width:100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col> -->
                        <el-col :span="8">
                            <el-form-item label="培养方案模板" prop="cultueTemplate">
                                <DictSelect
                                    v-model="createbasicForm.cultueTemplate"
                                    :data="options.cultueTemplate"
                                    clearable
                                    disabled
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="辅修专业" prop="profession">
                                <DictSelect
                                    v-model="createbasicForm.profession"
                                    :data="options.profession"
                                    :clearable="true"
                                    :filterable="true"
                                    disabled
                                    style="width: 100%;"
                                ></DictSelect>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="审批人" prop="approverPer">
                                <el-select
                                    v-model="createbasicForm.approverPer"
                                    :remote-method="remoteMethod"
                                    filterable
                                    remote
                                    :disabled="!disabledBtn"
                                    reserve-keyword
                                    placeholder="账号或用户名"
                                    style="width:100%"
                                >
                                    <el-option
                                        v-for="item in options.approverPer"
                                        :key="item.code"
                                        :label="item.name"
                                        :value="item.code"
                                    >
                                        <span style="float: left">{{ item.name }}</span>
                                        <span
                                            style="float: right; color: #8492a6; font-size: 13px"
                                        >{{ item.code }}</span>
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="录入人" prop="admissionPer">
                                <el-input
                                    v-model="createbasicForm.admissionPer"
                                    disabled
                                    style="width: 100%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </el-card>
            <el-card shadow="never">
                <div class="templateFont">章节划分</div>
                <!-- <div class="sectionBtn">
                    <el-button
                        v-if="disabledBtn"
                        type="primary"
                        @click="addsectionInfo"
                    >{{$t('minor.course.addBtn')}}</el-button>
                </div> -->
                <EduTable
                    :pagination="false"
                    :data="sectionData.list"
                    :summary-method="canTableData"
                >
                    <el-table-column label="章节名称" show-overflow-tooltip>
                        <template slot-scope="scope">
                            <el-input v-if="scope.row.isShow" v-model="scope.row.sectionName"></el-input>
                            <span v-else>{{scope.row.sectionName}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="英文名称" show-overflow-tooltip>
                        <template slot-scope="scope">
                            <el-input v-if="scope.row.isShow" v-model="scope.row.sectionNameEn"></el-input>
                            <span v-else>{{scope.row.sectionNameEn}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="内容导入方式">
                        <template slot-scope="scope">
                            <el-select
                                filterable
                                :disabled="scope.row.disabledFlag"
                                style="width: 100%"
                                v-model="scope.row.contentWay"
                            >
                                <el-option
                                    v-for="item in options.contentWay"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                />
                            </el-select>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column :label="$t('message.operating')">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="cancelRecord(scope.row,scope.$index)"
                                v-if="scope.row.isShow"
                                size="mini"
                            >取消</el-button>
                            <el-button
                                type="text"
                                v-if="!scope.row.isShow && disabledBtn"
                                @click="editlRecord(scope.row)"
                                size="mini"
                            >{{$t('message.edit')}}</el-button>
                            <el-button
                                type="text"
                                @click="deleteRecord(scope.$index,scope.row)"
                                size="mini"
                            >{{$t('message.delete')}}</el-button>
                            <el-button
                                type="text"
                                @click="saveRecord(scope.row)"
                                size="mini"
                                v-if="scope.row.isShow"
                            >保存</el-button>
                            <el-button
                                type="text"
                                @click="moveUpRecord(scope.$index,scope.row)"
                                size="mini"
                                v-if="!scope.row.isShow && scope.$index !=0 && disabledBtn"
                            >上移</el-button>
                            <el-button
                                type="text"
                                @click="moveDownRecord(scope.$index,scope.row)"
                                size="mini"
                                v-if="!scope.row.isShow  && scope.$index!=sectionData.list.length-1 && disabledBtn"
                            >下移</el-button>
                        </template>
                    </el-table-column> -->
                </EduTable>
            </el-card>
        </div>
        <div class="edu-page-warp" v-if="key=='addCourseType'">
            <el-card shadow="never">
                <!-- <div style="color:red;">
                    <i class="el-icon-warning sign_title"></i>
                    <div class="div_title">
                        <div>"课程类别" 会自动关联到相应学生,请填写每个课程类别的最低学分要求</div>
                        <div>课程类别学分来自于培养方案模板,课程学分要求不可低于模板分数要求</div>
                    </div>
                </div> -->
                <el-radio-group v-model="advancedType" size="medium" @change="autoCalculate">
                    <el-radio-button :label="item.key" v-for="item in advancedTypeMap" :key="item.key">{{item.value}}</el-radio-button>
                </el-radio-group>
                <div>
                    <el-table
                        :data="courseTyleData.list"
                        border
                        :row-style="rowStyle"
                        :header-cell-style="rowClass"
                        :span-method="objectSpanMethod"
                    >
                        <el-table-column label="课程性质" align="center" show-overflow-tooltip>
                            <template slot-scope="scope">{{scope.row.courseTypeName}}</template>
                        </el-table-column>
                         <el-table-column label="课程子性质" align="center" show-overflow-tooltip v-if="showCourseSubNature">
                            <template slot-scope="scope">{{scope.row.courseName}}</template>
                        </el-table-column>
                        <el-table-column label="微专业课程学分要求" align="center" show-overflow-tooltip>
                            <template slot-scope="scope">
                                <div v-if="scope.row.isTotal">{{scope.row.credits}}</div>
                                <div v-else>
                                    <el-input
                                        type="number"
                                        :disabled="!disabledBtn || advancedType != advancedTypeMap[0].key"
                                        v-model="scope.row.credits"
                                        @blur="autoCalculate"
                                        style="width:80px;"
                                    ></el-input>
                                </div>
                            </template>
                        </el-table-column>
                         <el-table-column label="辅修专业课程学分要求" align="center" show-overflow-tooltip v-if="advancedType != advancedTypeMap[0].key">
                            <template slot-scope="scope">
                                <div v-if="scope.row.isTotal">{{scope.row.credits2}}</div>
                                <div v-else>
                                    <el-input
                                        type="number"
                                        :disabled="!disabledBtn || advancedType != advancedTypeMap[1].key"
                                        v-model="scope.row.credits2"
                                        @blur="autoCalculate"
                                        style="width:80px;"
                                    ></el-input>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="辅修学位课程学分要求" align="center" show-overflow-tooltip v-if="advancedType != advancedTypeMap[0].key && advancedType != advancedTypeMap[1].key">
                            <template slot-scope="scope">
                                <div v-if="scope.row.isTotal">{{scope.row.credits3}}</div>
                                <div v-else>
                                    <el-input
                                        type="number"
                                        :disabled="!disabledBtn || advancedType != advancedTypeMap[2].key"
                                        v-model="scope.row.credits3"
                                        @blur="autoCalculate"
                                        style="width:80px;"
                                    ></el-input>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="百分比" align="center" show-overflow-tooltip>
                            <template slot-scope="scope">{{scope.row.percent}}</template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-card>
        </div>
        <div class="edu-page-warp" v-if="key=='addCourseSet'">
            <minor-table @selectChange="handelMintableChange" :templateId="cultureSchemeId" :type="2" :operationFlag="disabledBtn" :advancedType="advancedType" :schoolTerm="schoolTerm"/>
        </div>
        <div class="edu-page-warp" v-if="key=='addChapterSet'">
            <chapter-set
                ref="chapterSet"
                @returnList="returnList"
                :templateId="cultureSchemeId"
                :schoolTerm="schoolTerm"
                @tableClick="tableClick"
                :courseTyleData="courseTyleData.list"
                :type="2"
                :isEdit="disabledBtn"
                :advancedType="advancedTypeMap[2].key"
            />
        </div>
        <div class="edu-page-warp" v-if="key=='relationTable'">
            <relation-table
                ref="relationTable"
                :templateId="cultureSchemeId"
                :type="2"
                :schoolTerm="schoolTerm"
                :advancedType="advancedTypeMap[2].key"
                :data="relationTableData"
                :showCourseSubNature="showCourseSubNature"
                :courseTyleData="courseTyleData.list"
                @relationTableSaved="key = 'addChapterSet'"
            />
        </div>
        <div class="bottomDiv" v-if="key != 'cultureList'">
            <el-button
                @click="cancelUpChange"
                v-if="defaultValue == 4 && key !== 'viewCultureScheme' && disabledBtn && key!='relationTable' && isUpChange"
            >取消变更</el-button>
            <el-button
                @click="returnCultureList"
                v-if="key !== 'viewCultureScheme' && key!='relationTable'"
            >返回</el-button>
            <el-button
                type="primary"
                @click="nextStep('decrease')"
                v-if="defaultValue!==1 && key !== 'viewCultureScheme' && key!='relationTable' && key !='catChapter'"
            >上一步</el-button>
            <el-button
                type="primary"
                @click="save"
                v-if="key !== 'viewCultureScheme' && disabledBtn && key!='relationTable'"
            >保存</el-button>
            <el-button
                type="primary"
                @click="nextStep('increase')"
                v-if="defaultValue!==4 && key !== 'viewCultureScheme' && key!='relationTable'"
            >下一步</el-button>
            <el-button
                type="primary"
                @click="previewScheme"
                v-if="defaultValue ===4 && key !== 'viewCultureScheme' && disabledBtn && key!='relationTable'"
            >预览</el-button>
            <el-button
                type="primary"
                @click="submitCultureScheme"
                v-if="defaultValue ===4 && key !== 'viewCultureScheme' && disabledBtn && key!='relationTable'"
            >提交</el-button>
            <template v-if="defaultValue == 4 && key =='relationTable' && disabledBtn">
                <el-button @click="relationCancel">取消</el-button>
                <el-button type="primary" @click="relationOk">确定</el-button>
            </template>
        </div>
        <div class="edu-page-warp" v-if="key=='viewCultureScheme'">
            <cat-chapter
                ref="catChapter"
                :templateId="cultureSchemeId"
                :title="createbasicForm.schemeName"
                :schoolTerm="schoolTerm"
                :type="2"
                :advancedType="advancedTypeMap[2].key"
                @goBack="returnIndex"
            />
            <!-- <chapter-set :isEdit="false" :templateId="cultureSchemeId" :type="2" :advancedType="advancedTypeMap[2].key" />
            <div class="back">
                <el-button @click="returnIndex">返回</el-button>
            </div> -->
        </div>
        <edu-dialog ref="basicDialog" title="新增方案" width="70%" @close='closeBasicDialog'>
            <el-form
                :model="dialogBasicForm"
                ref="dialogBasicForm"
                label-width="100px"
                :rules="basicRules"
            >
                <el-row :gutter="24">
                    <el-col :span="24">
                        <el-form-item>
                            <el-checkbox v-model="schemeForm.checked">自动命名</el-checkbox>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="12">
                        <el-form-item label="方案名称" prop="schemeName">
                            <el-input
                                ref="schemeName"
                                v-model="dialogBasicForm.schemeName"
                                :placeholder="'自动命名：辅修年级+' + $t('minor.major.college') + '+辅修专业'"
                                style="width: 98%;"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="英文名称">
                            <el-input style="width: 98%;" v-model="dialogBasicForm.schemeNameEn"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <el-col :span="12">
                        <el-form-item label="辅修年级" prop="minorGrade">
                            <el-date-picker
                                v-model="dialogBasicForm.minorGrade"
                                type="year"
                                clearable
                                value-format="yyyy"
                                style="width: 98%;"
                                placeholder="请选择"
                                @change="getProfession('3')"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item :label="$t('minor.major.college')" prop="collegeCode">
                            <DictSelect
                                v-model="dialogBasicForm.collegeCode"
                                :data="options.college"
                                :clearable="true"
                                :filterable="true"
                                labelAll="请选择"
                                @change="getProfession('3')"
                                style="width: 98%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24">
                    <!-- <el-col :span="12">
                        <el-form-item
                            :label="$t('minor.course.advancedLevel')"
                            prop="advancedLevel"
                        >
                            <DictSelect
                                v-model="dialogBasicForm.advancedLevel"
                                :data="options.advancedLevel"
                                clearable
                                labelAll="请选择"
                                @change="getCultureTemplate(0)"
                                style="width: 98%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="12">
                        <el-form-item label="培养方案模板" prop="cultueTemplate">
                            <DictSelect
                                v-model="dialogBasicForm.cultueTemplate"
                                :data="options.cultueTemplate"
                                clearable
                                labelAll="请选择"
                                style="width: 98%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="辅修专业" prop="profession">
                            <DictSelect
                                v-model="dialogBasicForm.profession"
                                :data="options.profession"
                                :clearable="true"
                                :filterable="true"
                                labelAll="请选择"
                                style="width: 98%;"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <span slot="buttons">
                <el-button @click="closeBasicDialog">取消</el-button>
                <el-button type="primary" @click="confirmBasicDialog">确定</el-button>
            </span>
        </edu-dialog>
        <scheme-check
            ref="schemeCheck"
            :show="checkVisible"
            @closeWorkFlowDialog="closeWorkFlowDialog"
            @returnSchemeList="returnSchemeList"
            :id="cultureSchemeId"
            type="61"
        />
        <edu-dialog ref="progressDialog" title="批量创建" width="40%">
            <div class="progress_title">{{divTitle}}</div>
            <el-progress :percentage="percentage" :format="format" :stroke-width="10"></el-progress>
            <span slot="buttons">
                <el-button type="primary" @click="closeProgressDialog">关闭</el-button>
            </span>
        </edu-dialog>
        <el-dialog
            :visible.sync="showCopy"
            title="复制培养方案"
            width="35%"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form ref="copyForm" :model="copyForm" inline>
                <el-form-item
                    :rules="[{ required: true, message: '请选择辅修年级'}]"
                    label="辅修年级:"
                    prop="year"
                >
                    <el-select v-model="copyForm.year" placeholder="请选择" clearable>
                        <el-option
                            v-for="item in options.year"
                            :key="item.value"
                            :label="item.label + '级'"
                            :value="item.value"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item v-if="!!copyForm.year">
                    <i class="el-icon-warning"></i>
                    <span>选择辅修年级将会生成该辅修年级新的方案</span>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelCopy">取消</el-button>
                <el-button type="primary" @click="confirmCopy('copyForm')">保存</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import UTILS from "common/src/utils/utils";
import { queryDic } from "common/src/api/dictionary";
import { getValue } from "common/src/api/commonParam";
import { queryAdvancedLevel } from "common/src/api/minor/collegemajor";
import { findTeacherInfoList } from "common/src/api/studentinfo";
import { queryCourseTypeList } from "common/src/api/minor/minorCulturePlanManager";
import { querySwitch } from "common/src/api/minor/minorPower";
import {
    queryMinorCultureSchemeList,
    queryProfessionByCollege,
    deleteCultureScheme,
    queryCultureTemplate,
    revokeCultureScheme,
    saveCultureSchemeInfo,
    getCultureTemplateInfo,
    saveCultureSchemeSectionInfo,
    getCultureSectionBySchemeId,
    getCultureSchemeInfoBySchemeId,
    batchCultureScheme,
    getBatchCopyStatus,
    copyMinorSchemePre,
    changeCultureScheme,
    cancelChangeCultureScheme,
    deleteCultureSchemeList,
    findSchoolTermByCultureId
} from "common/src/api/minor/minorCultureScheme";
import { saveCourseTypeInfo } from "common/src/api/minor/minorCultureTemplate";
import { getSessionUser } from "common/src/api/session";
export default {
    components: {
        MinorTable: resolve => require(['../component/MinorTable'], resolve),
        ChapterSet: resolve => require(['../component/ChapterSet'], resolve),
        SchemeCheck: resolve => require(['../component/SchemeCheck'], resolve),
        RelationTable: resolve => require(['../component/RelationTable'], resolve),
        CatChapter: resolve => require(['../component/CatChapter'], resolve)
    },
    data() {
        return {
            key: "cultureList",
            canSelectFaculty: true,
            baseInfo: true,
            addBtn: true,
            disabledBtn: true,
            divTitle: "批量创建中...",
            relationTableData: null,
            timer: null,
            indexType: true,
            spanDataForModule: [],
            panDataForGroup: [],
            redisKey: "",
            optionType: 0, //0 表示编辑 1 表示查看
            isUpChange: false, //是否时变更
            isCloseBatchDialog: false,
            isTimer: false,
            defaultValue: 1,
            cultureSchemeId: 0,
            percentage: 0,
            tableData: {},
            checkVisible: false,
            randomId: "",
            chooseRows: [],
            templateIds: [],
            templateId: 0,
            courseTables: [],
            professionName: "",
            collegeName: "",
            templateCourseType: [],
            advancedLevelName: "",
            sectionTableNum: 0,
            isNextStep: false,
            sectionData: {
                list: []
            },
            topNavItems: [
                {
                    label: "基础信息",
                    index: 0,
                    value: 'addCultureScheme',
                    active: true
                },
                {
                    label: "课程类别",
                    index: 1,
                    value: 'addCourseType',
                    active: false
                },
                {
                    label: "课程设置",
                    index: 2,
                    value: 'addCourseSet',
                    active: false
                },
                {
                    label: "章节设置",
                    index: 3,
                    value: 'addChapterSet',
                    active: false
                }
            ],
            batchCultureScheme: {
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                cultueTemplate: "",
                profession: []
            },
            semesterSorts: [
                "一",
                "二",
                "三",
                "四",
                "五",
                "六",
                "七",
                "八",
                "九",
                "十"
            ],
            courseTyleData: {
                list: []
            },
            schemeForm: {
                checked: false
            },
            dialogBasicForm: {
                schemeName: "",
                schemeNameEn: "",
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                cultueTemplate: "",
                profession: ""
            },
            createbasicForm: {
                schemeName: "",
                schemeNameEn: "",
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                cultueTemplate: "",
                profession: "",
                approverPer: "",
                admissionPer: ""
            },
            queryParams: {
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                profession: "",
                status: ""
            },
            page: {
                pageNum: 1,
                pageSize: 20
            },
            options: {
                advancedLevel: [],
                college: [],
                contentWay: [
                    { label: "直接输入", value: "0" },
                    { label: "系统表格", value: "1" }
                ],
                /* 方案状态(0：草稿，1：通过 2：审核中 3:驳回 4：变更中) */
                pushStatus: [
                    { label: "草稿", value: 0 },
                    { label: "通过", value: 1 },
                    { label: "审核中", value: 2 },
                    { label: "驳回", value: 3 },
                    { label: "变更中", value: 4 }
                ],
                profession: [],
                cultueTemplate: [],
                approverPer: [],
                year: []
            },
            basicRules: {
                schemeName: [
                    {
                        required: true,
                        message: "方案名称不能为空",
                        trigger: "blur"
                    }
                ],
                minorGrade: [
                    {
                        required: true,
                        message: "辅修年级不能为空",
                        trigger: "change"
                    }
                ],
                collegeCode: [
                    {
                        required: true,
                        message: this.$t('minor.tip.collegeEmptyTip'),
                        trigger: "change"
                    }
                ],
                // advancedLevel: [
                //     {
                //         required: true,
                //         message: this.$t(
                //             "minor.culturePlan.advancedLevelNotNull"
                //         ),
                //         trigger: "change"
                //     }
                // ],
                cultueTemplate: [
                    {
                        required: true,
                        message: "培养方案模板不能为空",
                        trigger: "change"
                    }
                ],
                profession: [
                    {
                        required: true,
                        message: "辅修专业不能为空",
                        trigger: "change"
                    }
                ],
                approverPer: [
                    {
                        required: true,
                        message: "审批人不能为空",
                        trigger: "change"
                    }
                ],
                admissionPer: [
                    {
                        required: true,
                        message: "录入人不能为空",
                        trigger: "blur"
                    }
                ]
            },
            reBasicRules: {
                schemeName: [
                    {
                        required: true,
                        message: "方案名称不能为空",
                        trigger: "blur"
                    }
                ],
                approverPer: [
                    {
                        required: true,
                        message: "审批人不能为空",
                        trigger: "change"
                    }
                ],
                admissionPer: [
                    {
                        required: true,
                        message: "录入人不能为空",
                        trigger: "blur"
                    }
                ]
            },
            batchBasicRules: {
                minorGrade: [
                    {
                        required: true,
                        message: "辅修年级不能为空",
                        trigger: "change"
                    }
                ],
                collegeCode: [
                    {
                        required: true,
                        message: this.$t('minor.tip.collegeEmptyTip'),
                        trigger: "change"
                    }
                ],
                // advancedLevel: [
                //     {
                //         required: true,
                //         message: "进阶层次不能为空",
                //         trigger: "change"
                //     }
                // ],
                cultueTemplate: [
                    {
                        required: true,
                        message: "培养方案不能为空",
                        trigger: "change"
                    }
                ],
                profession: [
                    {
                        required: true,
                        message: "专业不能为空",
                        trigger: "change"
                    }
                ]
            },
            advancedType: '10002',
            advancedTypeMap: [
               {
                    key: 10002,
                    value: '微专业'
               },
               {    
                   key:10003,
                   value: '辅修专业',
               },
               {
                    key: 10004,
                    value: '辅修学位'
               }
            ],
            showCourseSubNature: false, //显示课程子性质
            showCopy: false,
            copyForm: {
                year: ''
            },
            schoolTerm: 0
        };
    },
    computed: {
        approveStatus() {
            return this.options.pushStatus.filter(item => item.value != 3)
        }
    },
    mounted() {
        if (!this.$checkMinor()) return;
        //this.getType();
        this.getOptions();
        //this.initCultureSchemeData();
    },
    watch: {
        "dialogBasicForm.minorGrade": function(val) {
            if (this.schemeForm.checked) {
                var obj = {};
                if (val == "") {
                    this.minorGrade = "";
                }
                this.dialogBasicForm.schemeName = this.joinData(
                    this.dialogBasicForm.minorGrade,
                    this.collegeName,
                    this.professionName,
                    this.advancedLevelName
                );
                this.$refs.schemeName.focus();
            }
        },
        "dialogBasicForm.collegeCode": function(val) {
            if (this.schemeForm.checked) {
                var obj = {};
                if (val == "") {
                    this.collegeName = "";
                } else {
                    obj = this.options.college.find(function(item) {
                        return item.value === val;
                    });
                    this.collegeName = obj.label;
                }

                this.dialogBasicForm.schemeName = this.joinData(
                    this.dialogBasicForm.minorGrade,
                    this.collegeName,
                    this.professionName,
                    this.advancedLevelName
                );
                this.$refs.schemeName.focus();
            }
        },
        "dialogBasicForm.profession": function(val) {
            if (this.schemeForm.checked) {
                var obj = {};
                if (val == "") {
                    this.professionName = "";
                } else {
                    obj = this.options.profession.find(function(item) {
                        return item.value === val;
                    });
                    this.professionName = obj.label;
                }

                this.dialogBasicForm.schemeName = this.joinData(
                    this.dialogBasicForm.minorGrade,
                    this.collegeName,
                    this.professionName,
                    this.advancedLevelName
                );
                this.$refs.schemeName.focus();
            }
        },
        "dialogBasicForm.advancedLevel": function(val) {
            if (this.schemeForm.checked) {
                var obj = {};
                let connector = "+";
                if (val == "") {
                    this.advancedLevelName = "";
                    connector = "";
                } else {
                    obj = this.options.advancedLevel.find(function(item) {
                        return item.value === val;
                    });
                    this.advancedLevelName = obj.label;
                }

                this.dialogBasicForm.schemeName = this.joinData(
                    this.dialogBasicForm.minorGrade,
                    this.collegeName,
                    this.professionName,
                    this.advancedLevelName
                );
                this.$refs.schemeName.focus();
            }
        }
    },
    methods: {
        format(percentage) {
            return percentage === 100 ? "100%" : percentage + "%";
        },
        //获取当前登录角色权限信息
        getType() {
            getSessionUser().then(res => {
                if ((res.code = 200)) {
                    if (!res.data.mockUser) {
                        if (res.data.user.type == 2) {
                            //学生
                            this.addBtn = false;
                        } else if (
                            res.data.user.innerRoles.join(",").indexOf("1") >=
                                0 &&
                            res.data.user.currentRole == "1"
                        ) {
                            //校管理员登录，放开审核操作
                            this.addBtn = true;
                            this.initAdvancedLevel("0");
                            //学院不可选择
                            this.canSelectFaculty = true;
                            this.queryParams.collegeCode = "";
                            //初始化培养方案信息
                            this.initCultureSchemeData();
                        } else if (
                            res.data.user.innerRoles.join(",").indexOf("2") >=
                                0 &&
                            res.data.user.innerRoles.join(",").indexOf("1") ==
                                -1 &&
                            res.data.user.currentRole == "1"
                        ) {
                            //学院教务登录，放开审核操作
                            this.addBtn = true;
                            this.initAdvancedLevel("0");
                            //学院不可选择
                            this.canSelectFaculty = false;
                            this.queryParams.collegeCode = this.options.college[0].value;
                            //初始化培养方案信息
                            this.initCultureSchemeData();
                        }
                    } else {
                        if (
                            !!res.data.mockUser &&
                            res.data.mockUser.type == 2
                        ) {
                            //学生
                            this.addBtn = false;
                        } else if (
                            !!res.data.mockUser &&
                            res.data.mockUser.innerRoles
                                .join(",")
                                .indexOf("1") >= 0 &&
                            res.data.mockUser.currentRole == "1"
                        ) {
                            //校管理员登录，放开审核操作
                            this.addBtn = true;
                            this.initAdvancedLevel("0");
                            //学院可选择
                            this.canSelectFaculty = true;
                            this.queryParams.collegeCode = "";
                            //初始化培养方案信息
                            this.initCultureSchemeData();
                        } else if (
                            !!res.data.mockUser &&
                            res.data.mockUser.innerRoles
                                .join(",")
                                .indexOf("2") >= 0 &&
                            res.data.mockUser.innerRoles
                                .join(",")
                                .indexOf("1") == -1 &&
                            res.data.mockUser.currentRole == "1"
                        ) {
                            //学院教务登录，放开审核操作
                            this.addBtn = true;
                            //学院不可选择
                            this.canSelectFaculty = false;
                            this.queryParams.collegeCode = this.options.college[0].value;
                            this.getProfession("2");
                            //初始化培养方案信息
                            this.initCultureSchemeData();
                        }
                    }
                }
            });
        },
        //字符串拼接
        joinData(a, b, c, d) {
            if (a) {
                b = "" + b;
            }
            if (a || b) {
                c = "" + c;
            }
            if (a || b || c) {
                d = "" + d;
            }
            return a + b + c + d;
        },
        breadcrumbChange(val) {
            if (val === "cultureList") {
                this.defaultValue = 1;
                this.page.pageNum = 1;
                this.initCultureSchemeData();
            }
        },
        //重置基础表单
        resetBasicForm() {
            this.createbasicForm.schemeName = "";
            this.createbasicForm.schemeNameEn = "";
            this.createbasicForm.approverPer = "";
            this.page.pageNum = 1;
            this.initCultureSchemeData();
        },
        remoteMethod(query, type) {
            if (query !== "") {
                setTimeout(() => {
                    findTeacherInfoList({
                        condition: query,
                        pageSize_: 100,
                        pageNum_: 0
                    }).then(res => {
                        if (res && res.code === 200) {
                            this.options.approverPer = res.data.list;
                            if (type) {
                                this.createbasicForm.approverPer = query;
                            }
                        }
                    });
                }, 200);
            } else {
                this.options.approverPer = [];
            }
        },
        //获取模板
        getCultureTemplate(type) {
            
            if (!type) {
                // this.initCultureTemplate(0, 0);
                this.getProfession("3");
            } else {
                // this.initCultureTemplate(2, 0);
                this.getProfession("2");
            }
        },
        //合并单元格
        arraySpanMethod({ row, column, rowIndex, columnIndex }) {
            if (row.isCategoryRow) {
                return {
                    rowspan: 1,
                    colspan: this.isRead ? 21 : 22 //根据操作列是否可见，计算课程分类合并列
                };
            }
            if (columnIndex == 1 || columnIndex == 9) {
                let spanData =
                    columnIndex == 1
                        ? this.spanDataForModule
                        : this.spanDataForGroup;
                let d = spanData.filter(ele => {
                    return ele.rowIndex == rowIndex;
                });
                if (d.length > 0) {
                    return {
                        rowspan: d[0].rowspan,
                        colspan: 1
                    };
                }
            }
        },
        initCultureSchemeData() {
            if (!this.$checkMinor()) return;
            let params = {
                pageNum_: this.page.pageNum,
                pageSize_: this.page.pageSize,
                minorGrade: this.queryParams.minorGrade,
                collegeCode: this.queryParams.collegeCode,
                advancedLevelCode: this.queryParams.advancedLevel,
                major: this.queryParams.profession,
                status: this.queryParams.status,
                projId: 1
            };
            queryMinorCultureSchemeList(params).then(res => {
                if (res.code == 200) {
                    this.tableData = res.data;
                }
            });
        },
        searchData() {
            this.page.pageNum = 1;
            this.initCultureSchemeData();
        },
        getOptions() {
            let data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["X_YX"]
            };
            queryDic(data).then(res => {
                this.options.college = [];
                UTILS.fillSelect(
                    {
                        college: "X_YX"
                    },
                    res.data,
                    this.options
                );
                //检查数据分权
                this.getType();
            });
            const now = new Date();
            const currentYear = now.getFullYear() + 1;
            const minYear = currentYear - 7;
            for (let year = currentYear + 4; year > minYear; year--) {
                const obj = {label: year, value: year};
                this.options.year.push(obj);
            }
        },
        initAdvancedLevel(isOnCampus) {
            let params = {
                isOnCampus: isOnCampus
            };
            this.options["advancedLevel"] = [];
            queryAdvancedLevel(params).then(res => {
                if (res.code == 200) {
                    for (let key = 0; key < res.data.length; key++) {
                        this.options["advancedLevel"].push({
                            value: res.data[key].advancedLevelCode,
                            label: res.data[key].advancedLevelName
                        });
                    }
                }
            });
        },
        initCourseTypeData() {
            this.courseTyleData.list = [];
            this.cultureRuleListCopy = [];
            //初始化课程类别
            let params = {
                id: this.cultureSchemeId,
                type: 2 //表示 1 模板 2 方案
            };
            queryCourseTypeList(params).then(res => {
                if (res.code == 200) {
                    let list = [];
                    let cultureRuleList =  res.data && res.data.cultureRuleList || [];
                    this.cultureRuleListCopy = _.cloneDeep(cultureRuleList);
                    this.showCourseSubNature = false; //是否显示子性质
                    let par =  cultureRuleList.filter( item =>  !Number(item.parentId));
                    par.forEach(p =>{
                        let children = [];
                        let isFirst = true;
                        cultureRuleList.forEach(e => {
                            if (p.labelId == e.parentId){
                                children.push({
                                    id: e.id,
                                    labelId: e.labelId,
                                    taringingId: e.taringingId,
                                    courseTypeName: p.label,
                                    courseName: e.label,
                                    credits: e.credit == 0 ? 0 : e.credit || '',
                                    credits2: e.credit2 == 0 ? 0 : e.credit2 || '',
                                    credits3: e.credit3 == 0 ? 0 : e.credit3 || '',
                                    percent: "0%",
                                    isFirst
                                });
                                isFirst = false;
                            }
                        });
                        if (!children.length) {
                            list.push({
                                id: p.id,
                                labelId: p.labelId,
                                taringingId: p.taringingId,
                                courseName: '',
                                courseTypeName: p.label,
                                credits: p.credit == 0 ? 0 : p.credit || '',
                                credits2: p.credit2 == 0 ? 0 : p.credit2 || '',
                                credits3: p.credit3 == 0 ? 0 : p.credit3 || '',
                                percent: "0%",
                                isFirst: true,
                                len: 1
                            });
                        }else {
                            this.showCourseSubNature = true;
                            children[0].len = children.length;
                            list = [...list, ...children]
                        }
                    })
                    list.push({
                        courseTypeName: "总计",
                        credits: 0,
                        credits2: 0,
                        credits3: 0,
                        percent: "0%",
                        isTotal: true
                    });
                    this.courseTyleData.list = [...list];
                    this.autoCalculate();
                }
            });
        },
        templateCourseTypeData() {
            this.templateCourseType = [];
            //初始化课程类别
            let params = {
                id: this.templateId,
                type: 1 //表示 1 模板 2 方案
            };
            queryCourseTypeList(params).then(res => {
                if (res.code == 200) {
                    let index = 0;
                    res.data.cultureRuleList &&
                        res.data.cultureRuleList.forEach(e => {
                            this.templateCourseType.push({
                                id: e.id,
                                labelId: e.labelId,
                                taringingId: e.taringingId,
                                courseTypeName: e.label,
                                credits: e.credit == 0 ? 0 : e.credit || '',
                                percent: "0%",
                            });
                            index++;
                        });
                }
            });
        },
        //初始化培养方案模板
        initCultureTemplate(type, templateId) {
            this.options.cultueTemplate = [];
            let advancedLevelCode = 0;
            let collegeCode = 0;
            let minorGrade = '';
            if (type === 0) {
                advancedLevelCode = this.dialogBasicForm.advancedLevel;
                minorGrade = this.dialogBasicForm.minorGrade;
                collegeCode = this.dialogBasicForm.collegeCode;
            } else if (type === 1) {
                advancedLevelCode = this.createbasicForm.advancedLevel;
                collegeCode = this.createbasicForm.collegeCode;
                minorGrade = this.createbasicForm.minorGrade;
            } else {
                advancedLevelCode = this.batchCultureScheme.advancedLevel;
                collegeCode = this.batchCultureScheme.collegeCode;
                minorGrade = this.batchCultureScheme.minorGrade;
            }
            let params = {
                advancedLevelCode: advancedLevelCode,
                minorGrade: type == 1 ? "" :minorGrade
            };
            queryCultureTemplate(params).then(res => {
                if (res.code == 200) {
                    res.data &&
                        res.data.forEach(e => {
                            this.options.cultueTemplate.push({
                                label: e.name,
                                value: e.id
                            });
                        });
                    if (templateId > 0) {
                        this.createbasicForm.cultueTemplate = templateId;
                    }
                }
            });
        },
        rowStyle({ row, rowIndex }) {
            return "text-align:center;";
        },
        rowClass({ row, rowIndex }) {
            return "text-align:center;";
        },
        resetQuery() {
            this.queryParams.minorGrade = "";
            if (this.canSelectFaculty) {
                this.queryParams.collegeCode = "";
            }
            else {
                this.queryParams.collegeCode = this.options.college[0] && this.options.college[0].value || '';
            }
            this.queryParams.advancedLevel = "";
            this.queryParams.status = "";
            this.page.pageNum = 1;
            this.initCultureSchemeData();
        },
        getCultureSchemeSectionInfo() {
            this.sectionData.list = [];
            getCultureSectionBySchemeId(this.cultureSchemeId).then(res => {
                if (res.code == 200) {
                    res.data &&
                        res.data.forEach(e => {
                            this.sectionData.list.push({
                                id: e.id,
                                sectionName: e.name,
                                sectionNameEn: e.nameEn,
                                contentWay: e.contentType + "",
                                disabledFlag: true,
                                isShow: false
                            });
                        });
                    this.sectionTableNum = res.data.length;
                }
            });
        },
        addCultureTemplateInfo() {
            if (!this.$checkMinor()) return;
            this.dialogBasicForm = {
                schemeName: "",
                schemeNameEn: "",
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                cultueTemplate: "",
                profession: ""
            };
            this.options.profession = [];
            this.options.cultueTemplate = [];
            //清空校验
            this.$refs.dialogBasicForm &&
                this.$refs.dialogBasicForm.resetFields();
            //初始化模板
            this.$refs.basicDialog.open();
        },
        //表格复选框选中或取消
        chooseRow(val) {
            this.chooseRows = val;
        },
        //添加章节
        addsectionInfo() {
            this.sectionData.list.push({
                isShow: true,
                disabledFlag: false,
                sectionId: "",
                sectionName: "",
                sectionNameEn: "",
                contentWay: "0"
            });
        },
        tableClick(val) {
            this.relationTableData = val;
            this.key = "relationTable";
        },
        //下一步
        nextStep(value) {
            if (value == "increase") {
                this.defaultValue++;
            } else {
                if (this.defaultValue == 1) {
                    return;
                }
                this.defaultValue--;
            }
            switch (this.defaultValue) {
                case 1:
                    this.key = "addCultureScheme";
                    break;
                case 2:
                    if (!this.optionType && value == "increase") {
                        if (this.checkSectionInfo()) {
                            this.saveSchemeSection();
                            if (!this.isNextStep) {
                                this.defaultValue--;
                            } else {
                                this.key = "addCourseType";
                                this.initCourseTypeData();
                            }
                        } else {
                            this.defaultValue--;
                        }
                    } else {
                        this.key = "addCourseType";
                        this.initCourseTypeData();
                    }
                    break;
                case 3:
                    if (!this.optionType) {
                        if (this.checkCourseType()) {
                            this.saveCourseTypeInfo();
                            // this.key = "addCourseSet";
                            this.courseSetBefore();
                        } else {
                            this.defaultValue--;
                        }
                    } else {
                        this.courseSetBefore();
                        //this.key = "addCourseSet";
                    }
                    break;
                case 4:
                    if (!this.addCourseWrongTip) {
                        this.key = "addChapterSet";
                    }else {
                        this.$message.warning(this.addCourseWrongTip);
                        this.defaultValue--;
                    }
                    break;
                default:
                    this.key = "addCultureScheme";
            }
        },
        courseSetBefore() {
            findSchoolTermByCultureId({cultureId: this.cultureSchemeId}).then(res =>{
                if (res && res.code == 200) {
                    let {finalSchoolTerm} = res.data || {};
                    this.schoolTerm = finalSchoolTerm || 0;
                }
            }).finally(() => {
                this.key = "addCourseSet";
            })
        },
        //删除章节
        deleteRecord(index, row) {
            this.sectionData.list.splice(index, 1);
            if (this.sectionTableNum >= 1) {
                this.sectionTableNum--;
            }
        },
        cancelRecord(index, row) {
            this.sectionData.list = JSON.parse(this.chapterData);
            this.sectionData.list[index].isShow = false;
            this.sectionData.list[index].disabledFlag = true;
        },
        getSelectRows() {
            this.templateIds = [];
            this.chooseRows.length > 0 &&
                this.chooseRows.forEach(e => {
                    if (e.id != null) {
                        this.templateIds.push(e.id);
                    }
                });
        },
        //保存章节
        saveRecord(row) {
            //校验章节名称不为空
            if (!row.sectionName) {
                this.$message.error({
                    type: "info",
                    message: "章节名称不能为空"
                });
            } else if (!row.sectionNameEn) {
                this.$message.error({
                    type: "info",
                    message: "英文名称不能为空"
                });
            } else {
                row.isShow = false;
                row.disabledFlag = true;
                this.sectionTableNum++;
            }
        },
        //编辑章节
        editlRecord(row) {
            if (this.sectionTableNum >= 1) {
                this.sectionTableNum--;
            }
            row.isShow = true;
            row.disabledFlag = false;
        },
        //章节上移
        moveUpRecord(index, row) {
            if (index > 0) {
                let upData = this.sectionData.list[index - 1];
                this.sectionData.list.splice(index - 1, 1);
                this.sectionData.list.splice(index, 0, upData);
            }
        },
        //章节下移
        moveDownRecord(index, row) {
            if (!(index + 1 === this.sectionData.list.length)) {
                let downData = this.sectionData.list[index + 1];
                this.sectionData.list.splice(index + 1, 1);
                this.sectionData.list.splice(index, 0, downData);
            }
        },
        getPushLable(value) {
            const pushStatu = this.options.pushStatus.find(
                t => t.value === value
            );
            if (pushStatu === "{}") {
                return value;
            } else {
                return pushStatu.label;
            }
        },
        autoCalculate() {
            let totalCredit = 0, totalCredit2 = 0, totalCredit3 = 0;
            //计算课程类别
            this.courseTyleData.list &&
                this.courseTyleData.list.forEach(e => {
                    if (!e.isTotal) {
                        totalCredit += Number(e.credits);
                        totalCredit2 += Number(e.credits2);
                        totalCredit3 += Number(e.credits3);
                    }
                });
            //计算百分比
            this.courseTyleData.list &&
                this.courseTyleData.list.forEach(e => {
                    let score = 0, totalScore = 0;
                    if (e.isTotal) {
                        e.credits = totalCredit;
                        e.credits2 = totalCredit2;
                        e.credits3 = totalCredit3;
                    }
                    if (this.advancedType == this.advancedTypeMap[0].key) {
                        score = Number(e.credits);
                        totalScore = totalCredit;
                    }
                    else if (this.advancedType == this.advancedTypeMap[1].key) {
                        score = Number(e.credits) + + Number(e.credits2);
                        totalScore = totalCredit + totalCredit2;
                    }else {
                        score = Number(e.credits) + + Number(e.credits2) + Number(e.credits3);
                        totalScore = totalCredit + totalCredit2 + totalCredit3;
                    }
                    e.percent = this.calculatePercent(
                        score,
                        totalScore
                    );
                   
                });
        },
        calculatePercent(num, total) {
            //计算百分比
            num = parseFloat(num);
            total = parseFloat(total);
            if (isNaN(num) || isNaN(total)) {
                return "-";
            }
            return total <= 0
                ? "0%"
                : Math.round((num / total) * 10000) / 100.0 + "%";
        },
        returnCultureList() {
            //返回模板列表
            this.returnList();
            // this.key = "cultureList";
            // this.initCultureSchemeData();
        },
        //批量创建
        batchAddCultureScheme() {
            if (!this.$checkMinor()) return;
            this.batchCultureScheme = {
                minorGrade: "",
                collegeCode: "",
                advancedLevel: "",
                cultueTemplate: "",
                profession: []
            };

            this.isCloseBatchDialog = true;
            //清空校验
            this.$refs.batchCultureScheme &&
                this.$refs.batchCultureScheme.resetFields();
            this.$refs.batchAddDialog.open();
        },
        getProfession(type) {
            let collegeCodeCondition = "0";
            //清空专业和培养方案模板
            this.options.profession = [];
            this.options.cultueTemplate = [];
            if (type == "1") {
                //查询
                collegeCodeCondition = this.queryParams.collegeCode;
            } else if (type == "2") {
                this.batchCultureScheme.cultueTemplate = "";
                this.batchCultureScheme.profession = [];
                //批量创建
                collegeCodeCondition = this.batchCultureScheme.collegeCode;
                //查询模板
                this.initCultureTemplate(2, 0);
            } else if (type == "3") {
                this.dialogBasicForm.cultureTe;
                this.dialogBasicForm.profession = "";
                this.dialogBasicForm.cultueTemplate = "";
                //新增
                collegeCodeCondition = this.dialogBasicForm.collegeCode;
                //查询模板
                this.initCultureTemplate(0, 0);
            } else if (type == "4") {
                collegeCodeCondition = this.createbasicForm.collegeCode;
            }
            this.options.profession = [];
            let params = {
                advancedCode: "",
                collegeCode: collegeCodeCondition,
                minorGrade: ""
            };
            
            if(type == "2"){
                params.advancedCode=this.batchCultureScheme.advancedLevel;
                params.minorGrade=this.batchCultureScheme.minorGrade;
            }else if(type == "3"){
                params.advancedCode=this.dialogBasicForm.advancedLevel;
                params.minorGrade=this.dialogBasicForm.minorGrade;
            }

            queryProfessionByCollege(params).then(res => {
                if (res.code == 200) {
                    this.options.profession = res.data;
                }
            });
        },
        //校验英文名称只能是字母、数字或者空格
        checkNameEn(value) {
            if (
                value &&
                value.toString().replace(/^[a-zA-Z\d\s]*$/, "") != ""
            ) {
                this.$message.error(this.$t("minor.tip.englishNameError"));
                return false;
            } else {
                return true;
            }
        },
        //删除培养方案
        deleteCultureScheme(row, isBatch) {
            this.$confirm("您确定要删除吗？", "删除", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                let promise, params = {};
                if (isBatch) {
                    this.getSelectRows();
                    if (this.templateIds.length === 0) {
                        this.$message({
                            type: 'warning',
                            message: '您还没有选择任何方案！'
                        })
                        return;
                    }
                    /* 筛选出审核通过的数据 */
                    let select = this.chooseRows.filter(el => {
                        return el.status == 1;
                    });
                    if (select.length > 0) {
                        this.$message.warning(
                            "所选数据中包含审核通过的数据，请去除后再进行删除！"
                        );
                        return;
                    }
                    params.ids = this.templateIds;
                    promise = deleteCultureSchemeList(params)
                }
                else {
                    params.id = row.id;
                    promise = deleteCultureScheme(params)
                }
                promise.then(res => {
                    if (res.code == 200) {
                        this.$message({
                            type: "success",
                            message: "删除成功!"
                        });
                        this.page.pageNum = 1;
                        this.initCultureSchemeData();
                    }
                });
            })
            .catch(() => {
                this.$message({
                    type: "info",
                    message: "已取消删除"
                });
            });
        },
        //撤销培养方案
        revokeCultureScheme(row) {
            let params = {
                idSet: row.id
            };
            this.$confirm("您确定要撤销吗？", "撤销", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    revokeCultureScheme(params).then(res => {
                        if (res.code == 200) {
                            this.$message({
                                type: "success",
                                message: "撤销成功!"
                            });
                            this.page.pageNum = 1;
                            this.initCultureSchemeData();
                        }
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消撤销"
                    });
                });
        },
        confirmCultureScheme() {
            this.$refs.createbasicForm.validate(valid => {
                if (valid) {
                    let params = {
                        name: this.createbasicForm.schemeName,
                        nameEn: this.createbasicForm.schemeNameEn,
                        collegeCode: this.createbasicForm.collegeCode,
                        advancedLevelCode: this.createbasicForm.advancedLevel,
                        major: this.createbasicForm.profession,
                        projId: 1,
                        approver: this.createbasicForm.approverPer,
                        entry: this.createbasicForm.admissionPer,
                        templateId: this.createbasicForm.cultueTemplate,
                        minorGrade: this.createbasicForm.minorGrade
                    };
                    saveCultureSchemeInfo(params).then(res => {
                        if (res.code == 200) {
                            this.cultureSchemeId = res.data.id;
                            //初始化章节
                            //this.getCultureSchemeSectionInfo();

                            this.$message({
                                type: "success",
                                message: "保存成功!"
                            });
                        }
                    });
                } else {
                    return false;
                }
            });
        },
        //保存信息
        save() {
            if (this.key === "addCultureScheme") {
                this.saveSchemeSection();
            } else if (this.key === "addCourseType") {
                this.saveCourseTypeInfo();
            } else if (this.key === "relationTable") {
                this.$refs.relationTable.saveTableDetail();
            } else if (this.key === "addChapterSet") {
                this.$refs.chapterSet.saveChapter();
            }else if (this.key == 'addCourseSet') {
                this.$message({
                    type: "success",
                    message: "保存成功"
                });
            }
        },
        //校验章节信息
        checkSectionInfo() {
            let flag = true;
            this.sectionData.list &&
                this.sectionData.list.forEach(e => {
                    if (!e.sectionName) {
                        flag = false;
                        return;
                    }
                });
            return flag;
        },
        //保存方案章节信息
        saveSchemeSection() {
            //校验必填项
            this.$refs.createbasicForm.validate(valid => {
                if (valid) {
                    //校验英文名称
                    this.isNextStep = false;
                    if (!this.checkNameEn(this.createbasicForm.schemeNameEn)) {
                        return false;
                    }
                    if (this.checkSectionInfo()) {
                        this.isNextStep = true;
                        let sectionList = [];
                        this.sectionData.list &&
                            this.sectionData.list.forEach(e => {
                                sectionList.push({
                                    id: e.id ? e.id : null,
                                    name: e.sectionName,
                                    nameEn: e.sectionNameEn,
                                    sortNo:
                                        this.sectionData.list.indexOf(e) + 1,
                                    contentType: e.contentWay,
                                    font: "黑体",
                                    fontSize: 18
                                });
                            });
                        let params = {
                            id: this.cultureSchemeId,
                            name: this.createbasicForm.schemeName,
                            nameEn: this.createbasicForm.schemeNameEn,
                            collegeCode: this.createbasicForm.collegeCode,
                            advancedLevelCode: this.createbasicForm
                                .advancedLevel,
                            major: this.createbasicForm.profession,
                            projId: 1,
                            approver: this.createbasicForm.approverPer,
                            entry: this.createbasicForm.admissionPer,
                            templateId: this.createbasicForm.cultueTemplate,
                            minorGrade: this.createbasicForm.minorGrade,
                            minorCultureSchemeDetailList: sectionList
                        };
                        saveCultureSchemeSectionInfo(params).then(res => {
                            if (res.code == 200) {
                                this.$message({
                                    type: "success",
                                    message: "保存成功!"
                                });
                            }
                        });
                    } else {
                        this.$message.error("章节名称或英文名称不能为空");
                    }
                } else {
                    this.isNextStep = false;
                    return false;
                }
            });
        },
        //保存培养方案的基本信息
        confirmBasicDialog() {
            this.$refs.dialogBasicForm.validate(valid => {
                if (valid) {
                    //校验英文名称
                    if (!this.checkNameEn(this.dialogBasicForm.schemeNameEn)) {
                        return;
                    }
                    let params = {
                        name: this.dialogBasicForm.schemeName,
                        nameEn: this.dialogBasicForm.schemeNameEn,
                        collegeCode: this.dialogBasicForm.collegeCode,
                        advancedLevelCode: this.dialogBasicForm.advancedLevel,
                        major: this.dialogBasicForm.profession,
                        projId: 1,
                        approver: "",
                        entry: "",
                        templateId: this.dialogBasicForm.cultueTemplate,
                        minorGrade: this.dialogBasicForm.minorGrade
                    };
                    saveCultureSchemeInfo(params).then(res => {
                        if (res.code == 200) {
                            this.cultureSchemeId = res.data.id;
                            this.$refs.basicDialog.close();
                            this.$message({
                                type: "success",
                                message: "保存成功!"
                            });
                            this.page.pageNum = 1;
                            this.initCultureSchemeData();
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
                } else {
                    return false;
                }
            });
        },
        //编辑培养方案
        async editCultureScheme(row) {
            if (!this.$checkMinor()) return;
            await querySwitch({departmentCode:row.collegeCode,grade:row.minorGrade});            
            this.remoteMethod(row.approver, 1);
            this.disabledBtn = true;
            this.isUpChange = row.status == 4 ? true : false;
            this.optionType = 0;
            this.key = "addCultureScheme";
            this.templateId = row.templateId;
            this.createbasicForm = {
                schemeName: row.name,
                schemeNameEn: row.nameEn,
                minorGrade: row.minorGrade + "",
                collegeCode: row.collegeCode,
                advancedLevel: row.advancedLevelCode + "",
                profession: row.major,
                approverPer: ""
            };
            //初始化模板，并赋值
            this.initCultureTemplate(1, row.templateId);
            this.createbasicForm.admissionPer = row.createBy;
            // this.createbasicForm.admissionPer = JSON.parse(
            //     localStorage.getItem("user")
            // ).name;

            //初始化专业
            this.getProfession("4");

            //初始化章节信息
            this.cultureSchemeId = row.id;
            this.getCultureSchemeSectionInfo();

            //初始化模板课程类别
            this.templateCourseTypeData();
        },
        //关闭基本信息
        closeBasicDialog() {
            this.$refs.basicDialog.close();
        },
        //校验课程类型信息
        checkCourseType() {
            let flag = true;
            let msg;
            this.templateCourseType.forEach(p => {
                let sameLabelItem = this.courseTyleData.list.find(e => p.labelId == e.labelId);
                if (sameLabelItem) {
                    let credits = 0;
                    if (this.advancedType == this.advancedTypeMap[0].key) {
                        credits = Number(sameLabelItem.credits);
                    }
                    else if (this.advancedType == this.advancedTypeMap[1].key) {
                        credits = Number(sameLabelItem.credits) + Number(sameLabelItem.credits2);
                    }
                    else {
                        credits = Number(sameLabelItem.credits) + Number(sameLabelItem.credits2) +  Number(sameLabelItem.credits3);
                    }
                    if (Number(sameLabelItem.credits) < 0 || Number(sameLabelItem.credits2) < 0 || Number(sameLabelItem.credits3) < 0) {
                        flag = false;
                        msg = '学分输入有误';
                    }
                    else if (credits < p.credits && flag) {
                        let name = sameLabelItem.courseName || sameLabelItem.courseTypeName;
                        msg = `${name}学分要求不可低于模板分数要求`;
                        flag = false;
                    }
                }
            })
            !flag && this.$message.warning({
                type:'warning',
                message: msg        
            })
            return flag;
            // this.templateCourseType &&
            //     this.templateCourseType.forEach(e => {
            //         if (
            //             parseFloat(
            //                 this.courseTyleData.list[e.courseType].credits
            //             ) < parseFloat(e.credits) &&
            //             e.courseType === 0
            //         ) {
            //             this.$message.warning(
            //                 "必修课程学分要求不可低于模板分数要求"
            //             );
            //             return (flag = false);
            //         } else if (
            //             parseFloat(
            //                 this.courseTyleData.list[e.courseType].credits
            //             ) < parseFloat(e.credits) &&
            //             e.courseType === 1
            //         ) {
            //             this.$message.warning(
            //                 "选修课程学分要求不可低于模板分数要求"
            //             );
            //             return (flag = false);
            //         } else if (
            //             parseFloat(
            //                 this.courseTyleData.list[e.courseType].credits
            //             ) < parseFloat(e.credits) &&
            //             e.courseType === 2
            //         ) {
            //             this.$message.warning(
            //                 "其他课程学分要求不可低于模板分数要求"
            //             );
            //             return (flag = false);
            //         }
            //     });
            //return flag;
        },
        //保存课程类别信息
        saveCourseTypeInfo() {
            // let flag = false;
            // this.courseTyleData.list.forEach((el, index) => {
            //     if (!Number.isFinite(parseFloat(el.credits))) {
            //         flag = true;
            //     }
            // });
            // if (flag) {
            //     this.$message.warning("学分输入有误，请核对后再进行保存");
            //     return;
            // }
            if (!this.$checkMinor()) return;
            //获取章节信息
            if (this.checkCourseType()) {
                let courseTypeList = [];
                this.cultureRuleListCopy && this.cultureRuleListCopy.forEach(e =>{
                    let par = {
                        id: e.id,
                        labelId: e.labelId,
                        credit: e.credit || 0,
                        taringingId: this.cultureSchemeId,
                        parentId: e.parentId,
                        type: 2
                    }
                    let specItem = this.courseTyleData.list.find(item => item.labelId == e.labelId);
                    if (specItem) {
                        par.credit = specItem.credits || 0;
                        par.credit2 = specItem.credits2 || 0;
                        par.credit3 = specItem.credits3 || 0;
                    }
                    courseTypeList.push(par)
                })
                // this.courseTyleData.list &&
                //     this.courseTyleData.list.forEach(e => {
                //         if (!e.isTotal) {
                //             courseTypeList.push({
                //                 id: e.id,
                //                 labelId: e.labelId,
                //                 credit: e.credits,
                //                 credit2: e.credits2,
                //                 credit3: e.credits3,
                //                 taringingId: this.cultureSchemeId,
                //                 parentId: e.parentId
                //                 type: 2
                //             });
                //         }
                //     });
                // this.remainCourseData && this.remainCourseData.forEach(p =>{
                //     courseTypeList.push({
                //         id: p.id,
                //         labelId: p.labelId,
                //         credit: p.credit,
                //         parentId: p.parentId
                //         taringingId: this.cultureSchemeId,
                //         type: 2
                //     })
                // })
                let params = {
                    id: this.cultureSchemeId,
                    minorCultureRuleList: courseTypeList
                };
                saveCourseTypeInfo(params).then(res => {
                    if (res.code == 200) {
                        this.isSaved = true;
                        this.$message({
                            message: "保存成功",
                            type: "success"
                        });
                    }
                });
            }
        },
        //提交培养方案流程
        submitCultureScheme() {
            if (this.defaultValue === 4) {
                this.$refs.schemeCheck.initCultureSchemeInfo();
                this.checkVisible = true;
            }
        },
        //关闭培养方案流程
        returnSchemeList() {
            // this.checkVisible = false;
            // this.defaultValue = 1;
            // this.key = "cultureList";
            // this.initCultureSchemeData();
            this.returnList();
        },
        closeWorkFlowDialog() {
            this.checkVisible = false;
        },
        //分页查询
        pageChange(page) {
            this.page.pageNum = page.pageNum;
            this.page.pageSize = page.pageSize;
            this.initCultureSchemeData();
        },
        //关闭批量窗口
        cancelBatch() {
            this.$refs.batchAddDialog.close();
        },
        //确认进行批量数据
        confirmBatch() {
            this.$refs.batchCultureScheme.validate(valid => {
                if (valid) {
                    let params = {
                        collegeCode: this.batchCultureScheme.collegeCode,
                        advancedLevelCode: this.batchCultureScheme
                            .advancedLevel,
                        majorSet: this.batchCultureScheme.profession,
                        projId: 1,
                        createType: 2,
                        templateId: this.batchCultureScheme.cultueTemplate,
                        minorGrade: this.batchCultureScheme.minorGrade
                    };
                    this.$refs.progressDialog.open();
                    batchCultureScheme(params).then(res => {
                        if (res.code == 200) {
                            this.redisKey = res.data.redisKey;
                            this.isTimer = true;
                            this.getBatchCopyStatus(res.data.redisKey);
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
                } else {
                    return false;
                }
            });
        },
        //关闭进度条弹出框
        closeProgressDialog() {
            this.$refs.progressDialog.close();
            if (this.isCloseBatchDialog) {
                this.$refs.batchAddDialog.close();
            }
        },
        //轮训查询批量复制进度进度
        getBatchCopyStatus(key) {
            getBatchCopyStatus(key).then(res => {
                if (res.code == 200) {
                    if (res.data) {
                        let percentage =
                            (res.data.percentage.split(":")[0] /
                                res.data.percentage.split(":")[1]) *
                            100;
                        if (percentage == 100) {
                            this.divTitle = "批量创建成功";
                            clearInterval(this.timer);
                            this.isCloseBatchDialog = true;
                            this.initCultureSchemeData();
                        } else {
                            this.timer = setInterval(
                                this.getBatchCopyStatus(this.redisKey),
                                10 * 2000
                            );
                        }
                        this.percentage = percentage;
                    }
                } else {
                    this.$message.error(res.msg);
                }
            });
        },
        returnList() {
            this.key = "cultureList";
            this.isUpChange = false;
            this.checkVisible = false;
            this.defaultValue = 1;
            this.page.pageNum = 1;
            this.initCultureSchemeData();
        },
        viewRecord(row) {
            this.indexType = false;
            this.defaultValue = 1;
            this.optionType = 1;
            this.disabledBtn = false;
            this.key = "addCultureScheme";
            this.cultureSchemeId = row.id;
            this.remoteMethod(row.approver, 1);
            this.createbasicForm = {
                schemeName: row.name,
                schemeNameEn: row.nameEn,
                minorGrade: row.minorGrade + "",
                collegeCode: row.collegeCode,
                advancedLevel: row.advancedLevelCode + "",
                profession: row.major,
                approverPer: ""
            };
            //初始化模板，并赋值
            this.initCultureTemplate(1, row.templateId);
            this.createbasicForm.admissionPer = row.createBy;
            //初始化专业
            this.getProfession("4");
            this.getCultureSchemeSectionInfo();
        },
        //预览培养方案
        previewScheme() {
            this.indexType = true;
            this.key = "viewCultureScheme";
        },
        //返回对应的位置
        returnIndex() {
            if (this.indexType) {
                this.key = "addChapterSet";
            } else {
                this.key = "cultureList";
                this.returnList();
            }
        },
        clickItem(item, index) {
            this.topNavItems.forEach(item => {
                item.active = item.index === index;
            });
            this.defaultValue = index + 1;
            this.key = item.value;
        },
        upChangeBefore(row) {
            let param = {
                id: row.id
            }
            return changeCultureScheme(param);
        },
        async upChange(row) {
            let {code, data} = await this.upChangeBefore(row);
            if (code == 200) {
                row = data || {};
            }else {
                return;
            }
            this.isUpChange = true;
            this.remoteMethod(row.approver, 1);
            this.disabledBtn = true;
            this.optionType = 0;
            this.key = "addCultureScheme";
            this.templateId = row.templateId;
            this.cultureSchemeId = row.id;
            this.createbasicForm = {
                schemeName: row.name,
                schemeNameEn: row.nameEn,
                minorGrade: row.minorGrade + "",
                collegeCode: row.collegeCode,
                advancedLevel: row.advancedLevelCode + "",
                profession: row.major,
                approverPer: ""
            };
            //初始化模板，并赋值
            this.initCultureTemplate(1, row.templateId);
            this.createbasicForm.admissionPer = row.createBy;
            this.getProfession("4");
            //初始化章节信息
            this.getCultureSchemeSectionInfo();
            //初始化模板课程类别
            this.templateCourseTypeData();
            
        },
        objectSpanMethod({ row, columnIndex }) {
            if (columnIndex === 0 && !row.isTotal) {
                if (row.isFirst) {
                    return {
                        rowspan: row.len,
                        colspan: 1
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0
                    };
                }
            }
        },
        confirmCopy() {
            this.$refs.copyForm.validate(valid => {
                if (valid) {
                    let param = {
                        minorGrade: this.copyForm.year,
                        idSet: this.templateIds
                    }
                    copyMinorSchemePre(param).then(res => {
                        if (res.code === 200) {
                            this.$message({
                                type: "success",
                                message: "复制成功"
                            });
                            this.templateIds = [];
                            this.cancelCopy();
                            this.page.pageNum = 1;
                            this.initCultureSchemeData();
                        }
                    })
                }
            });
        },
        copy() {
            this.getSelectRows();
            if (this.templateIds.length === 0) {
                this.$message({
                    type: "warning",
                    message: "请选择要复制的培养方案"
                });
                return;
            }
            this.showCopy = true;
        },
        cancelCopy() {
            this.showCopy = false;
            this.$refs.copyForm.resetFields();
        },
        exprtTraining() {
            this.getSelectRows();
            if (this.templateIds.length === 0) {
                this.$message({
                    type: "warning",
                    message: '您还没有选择任何方案！'
                })
                return
            }
            let  cultureIds = this.templateIds.join(',');
            window.open(`/api/cultureservice/minorCultureSchemePre/exportMinorCultureSchemeZip?cultureIds=${cultureIds}`);
        },
        relationCancel() {
            this.key = 'addChapterSet';
        },
        relationOk() {
            this.save();
        },
        async cancelUpChange() {
            let param = {
                id: this.cultureSchemeId
            }
            let {code} = await cancelChangeCultureScheme(param);
            if (code == 200) {
                this.$message({
                    type: "success",
                    message: "取消成功"
                });
                this.returnList();
            }
        },
        handelMintableChange(val, message) {
            this.addCourseWrongTip = message;
            if (this.optionType) {
                this.addCourseWrongTip = null;
            }
        },
        previewCulture(row) {
            this.$router.push({
                name: 'minorCultureSchemeView',
                params: {
                    id: row.id,
                    title: row.name,
                    currentPath: this.$route.path
                }

            })
        }
    }
};
</script>
<style scoped lang="scss">
.first_title {
    font-size: 18px;
    font-family: "微软雅黑";
    color: #2b3b4e;
    padding: 0px 0px 16px;
}
.btn {
    text-align: right;
    padding: 0px 0px 16px;
}
.templateFont {
    font-family: PingFangSC-Medium;
    font-size: 18px;
    color: #2b3b4e;
    letter-spacing: 0;
    line-height: 20px;
    font-weight: bold;
    float: left;
}
.progress_title {
    text-align: center;
    line-height: 90px;
}
.sign_title {
    float: left;
    line-height: 30px;
}
.div_title {
    float: left;
    margin: 0 0 0 15px;
}
.title-span {
    margin-bottom: -5px;
    margin-left: 5px;
    span {
        cursor: pointer;
        display: inline-block;
        padding-right: 20px;
        color: #8896a7;
        font-weight: 400;
        border-right: 0;
        font-size: 16px;
    }
    span.active {
        padding: 8px 15px;
        color: #66b1ff;
        background: #fff;
        font-weight: 500;
        font-size: 16px;

    }
}
.stepstyle .el-step.is-horizontal .el-step__line {
    top: 15px;
}
.stepstyle .el-step__icon {
    width: 32px;
    height: 32px;
}
.stepstyle {
    width: 80%;
    margin: 0 auto 16px;
}
.returnBtn {
    float: right;
}
.parentDiv {
    padding: 0 0 24px;
}
.sectionBtn {
    margin: 25px 0;
    float: right;
}
.bottomDiv {
    float: right;
    margin: 20px 0;
}
</style>




